<?php
/*
 * This file is part of the Geek-Zoo Projects.
 *
 * @copyright (c) 2010 Geek-Zoo Projects More info http://www.geek-zoo.com
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License
 * @author quqiang <quqiang@geek-zoo.com>
 *
 */
require ROOT_PATH.'/Helper/front_abstract.php';

class Action extends front_abstract
{
	function index(){
		
		$type = _GET('type', 0);
		
		$newpost_id=array();
		
		$slider=_GET('slider', 0);
		
		if(empty($this->info['id'])){
			$this->msg("您需要登录进行操作");
		}
		
		if($slider){
			
		$gettime = get_slider_time($slider);
		
		if ($type == 0 || $type == 1) {
			$where = " && add_time > {$gettime} and status='0' ";
		} else {
			$where = " && add_time > {$gettime}  ";
		}
		
		}else{
			if ($type == 0 || $type == 1) {
				$where = " and status='0' ";
			} else {
				$where = "";
			}
			
		}
		
		switch ($type){
			
			case 0:
			
			$fetch = _model('post')->getList("where user_id = ".$this->info['id'].$where." order by add_time desc", new Pager(20));
			
			if(empty($fetch)){
				
				$this->msg("没有贴子");
			}
			
			break;
			
			case 1:
						
			$fetch = _model('comment')->getList("where user_id =".$this->info['id'].$where." order by add_time desc ", new Pager(20));
			
			if(empty($fetch)){
				
				$this->msg("没有回复");
			}
			
			break;
			
			case 2:
			
			
			$user_id = _model('favor')->getList("where user_id = ".$this->info['id'].$where." order by add_time desc");
			
			foreach($user_id as $val){
				
				$newpost_id[]=$val['post_id'];
				
			}
			$newid=implode(",", $newpost_id);
			
			if(empty($newid)){
				$this->msg("没有收藏");
			}
			
			$fetch = _model('post')->getList("where id in (".$newid.$where.") order by add_time desc", new Pager(20));
			
			break;
			
		}
		
		if(empty($type)){
			
			$fetch = _model('post')->getList("where user_id = ".$this->info['id'].$where." order by add_time desc", new Pager(20));
			
		}
		
		$this->view->assign($fetch);
		
		$this->view->display('front/post.html');
	}
}
